home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / WIN_PRO / DS-1.ZIP;1 / RUNTIME.ZIP / KEYWORD.R < prev    next >
Encoding:
Text File  |  1992-02-10  |  16.6 KB  |  680 lines

  1. /*
  2.  * File: keyword.r
  3.  *  Contents: all keywords
  4.  */
  5.  
  6. "&allocated - the space used in the storage regions:"
  7. " total, static, string, and block"
  8. keyword{4} allocated
  9.    abstract {
  10.       return integer
  11.       }
  12.    inline {
  13.       suspend C_integer stattotal + strtotal + blktotal;
  14.       suspend C_integer stattotal;
  15.       suspend C_integer strtotal;
  16.       return  C_integer blktotal;
  17.       }
  18. end
  19.  
  20. "&clock - a string consisting of the current time of day"
  21. keyword{1} clock
  22.    abstract {
  23.       return string
  24.       }
  25.    inline {
  26.       struct cal_time ct;
  27.       char sbuf[9], *tmp;
  28.  
  29.       getitime(&ct);
  30.       sprintf(sbuf,"%02d:%02d:%02d", ct.hour, ct.minute, ct.second);
  31.       Protect(tmp = alcstr(sbuf,(word)8), runerr(0));
  32.       return string(8, tmp);
  33.       }
  34. end
  35.  
  36. "&collections - the number of collections: total, triggered by static requests"
  37. " triggered by string requests, and triggered by block requests"
  38. keyword{4} collections
  39.    abstract {
  40.       return integer
  41.       }
  42.    inline {
  43.       suspend C_integer coll_tot;
  44.       suspend C_integer coll_stat;
  45.       suspend C_integer coll_str;
  46.       return  C_integer coll_blk;
  47.       }
  48. end
  49.  
  50. "¤t - the currently active co-expression"
  51. keyword{1} current
  52.    abstract {
  53.       return co_expression
  54.       }
  55.    inline {
  56.       return k_current;
  57.       }
  58. end
  59.  
  60. "&date - the current date"
  61. keyword{1} date
  62.    abstract {
  63.       return string
  64.       }
  65.    inline {
  66.       struct cal_time ct;
  67.       char sbuf[11], *tmp;
  68.  
  69.       getitime(&ct);
  70.       sprintf(sbuf, "%04d/%02d/%02d", ct.year, ct.month_no, ct.mday);
  71.       Protect(tmp = alcstr(sbuf,(word)10), runerr(0));
  72.       return string(10, tmp);
  73.       }
  74. end
  75.  
  76. "&dateline - current date and time"
  77. keyword{1} dateline
  78.    abstract {
  79.       return string
  80.       }
  81.    body {
  82.       struct cal_time ct;
  83.       char sbuf[MaxCvtLen];
  84.       int hour;
  85.       char *merid, *tmp;
  86.       int i;
  87.  
  88.       getitime(&ct);
  89.       if ((hour = ct.hour) >= 12) {
  90.          merid = "pm";
  91.          if (hour > 12)
  92.             hour -= 12;
  93.          }
  94.       else {
  95.          merid = "am";
  96.          if (hour < 1)
  97.             hour += 12;
  98.          }
  99.       sprintf(sbuf, "%s, %s %d, %d  %d:%02d %s", ct.wday, ct.month_nm,
  100.          ct.mday, ct.year, hour, ct.minute, merid);
  101.        i = strlen(sbuf);
  102.        Protect(tmp = alcstr(sbuf, i), runerr(0));
  103.        return string(i, tmp);
  104.        }
  105. end
  106.  
  107. "&digits - a cset consisting of the 10 decimal digits"
  108. keyword{1} digits
  109.    constant '0123456789'
  110. end
  111.  
  112. "&e - the base of the natural logarithms"
  113. keyword{1} e
  114.    constant 2.718281828459045
  115. end
  116.  
  117. "&error - enable/disable error conversion"
  118. keyword{1} error
  119.    abstract {
  120.       return kywdint
  121.       }
  122.    inline {
  123.       return kywdint(&kywd_err);
  124.       }
  125. end
  126.  
  127. "&errornumber - error number of last error converted to failure"
  128. keyword{0,1} errornumber
  129.    abstract {
  130.       return integer
  131.       }
  132.    inline {
  133.       if (k_errornumber == 0)
  134.          fail;
  135.       return C_integer k_errornumber;
  136.       }
  137. end
  138.  
  139. "&errortext - error message of last error converted to failure"
  140. keyword{0,1} errortext
  141.    abstract {
  142.       return string
  143.       }
  144.    inline {
  145.       if (k_errornumber == 0)
  146.          fail;
  147.       return C_string k_errortext;
  148.       }
  149. end
  150.  
  151. "&errorvalue - erroneous value of last error converted to failure"
  152. keyword{0,1} errorvalue
  153.    abstract {
  154.       return AnyType
  155.       }
  156.    inline {
  157.       if (have_errval)
  158.          return k_errorvalue;
  159.       else
  160.          fail;
  161.       }
  162. end
  163.  
  164. "&errout - standard error output."
  165. keyword{1} errout
  166.     abstract {
  167.        return file
  168.        }
  169.     inline {
  170.        return file(&k_errout);
  171.        }
  172. end
  173.  
  174. "&fail - just fail"
  175. keyword{0} fail
  176.    abstract {
  177.       return empty_type
  178.       }
  179.    inline {
  180.       fail;
  181.       }
  182. end
  183.  
  184. #if !COMPILER
  185. "&eventcode - event in monitored program"
  186. keyword{0,1} eventcode
  187.    abstract {
  188.       return string
  189.       }
  190.    inline {
  191.       fail;
  192.       }
  193. end
  194.  
  195. "&eventvalue - value from event in monitored program"
  196. keyword{0,1} eventvalue
  197.    abstract {
  198.       return AnyType
  199.       }
  200.    inline {
  201.       fail;
  202.       }
  203. end
  204. #endif                    /* !COMPILER */
  205.  
  206. "&features - generate strings idenifying the features in this version of Icon"
  207. keyword{1,*} features
  208.    abstract {
  209.       return string
  210.       }
  211.    body {
  212. #if AMIGA
  213.       suspend C_string "Amiga";
  214. #endif                    /* AMIGA */
  215. #if ARM
  216.       suspend C_string "Acorn Archimedes";
  217. #endif                    /* ARM */
  218. #if ATARI_ST
  219.       suspend C_string "Atari ST";
  220. #endif                    /* ATARI_ST */
  221. #if VM
  222.       suspend C_string "CMS";
  223. #endif                    /* VM */
  224. #if MACINTOSH
  225.       suspend C_string "Macintosh";
  226. #endif                    /* MACINTOSH */
  227. #if MSDOS
  228. #if INTEL_386 || ZTC_386 || HIGHC_386
  229.       suspend C_string "MS-DOS/386";
  230. #else                    /* INTEL_386 || ZTC_386 ... */
  231.       suspend C_string "MS-DOS";
  232. #endif                    /* INTEL_386 || ZTC_386 ... */
  233. #endif                    /* MSDOS */
  234. #if MVS
  235.       suspend C_string "MVS";
  236. #endif                    /* MVS */
  237. #if OS2
  238.       suspend C_string "OS/2";
  239. #endif                    /* OS2 */
  240. #if PORT
  241.       suspend C_string "PORT";
  242. #endif                    /* PORT */
  243. #if UNIX
  244.       suspend C_string "UNIX";
  245. #endif                    /* VM */
  246. #if VMS
  247.       suspend C_string "VMS";
  248. #endif                    /* VMS */
  249. #if COMPILER
  250.       suspend C_string "compiled";
  251. #else                    /* COMPILER */
  252.       suspend C_string "interpreted";
  253. #endif                    /* COMPILER */
  254. #if EBCDIC != 1
  255.       suspend C_string "ASCII";
  256. #else                    /* EBCDIC != 1 */
  257.       suspend C_string "EBCDIC";
  258. #endif                    /* EBCDIC */
  259. #ifdef IconCalling
  260.       suspend C_string "calling to Icon";
  261. #endif                    /* IconCalling */
  262. #ifdef Coexpr
  263.       suspend C_string "co-expressions";
  264. #endif                    /* Coexpr */
  265. #ifdef Header
  266.       suspend C_string "direct execution";
  267. #endif                    /* Header */
  268. #ifdef EnvVars
  269.       suspend C_string "environment variables";
  270. #endif                    /* EnvVars */
  271. #ifdef TraceBack
  272.       suspend C_string "error trace back";
  273. #endif                    /* TraceBack */
  274. #ifdef EventMon
  275.       suspend C_string "event monitoring";
  276. #endif                    /* EventMon */
  277. #ifdef ExecImages
  278.       suspend C_string "executable images";
  279. #endif                    /* ExecImages */
  280. #ifndef    FixedRegions            /* FixedRegions */
  281.       suspend C_string "expandable regions";
  282. #endif                    /* FixedRegions */
  283. #ifdef ExternalFunctions
  284.       suspend C_string "external functions";
  285. #endif                    /* ExternalFunctions */
  286. #ifdef FixedRegions
  287.       suspend C_string "fixed regions";
  288. #endif                    /* FixedRegions */
  289. #ifdef KeyboardFncs
  290.       suspend C_string "keyboard functions";
  291. #endif                    /* Keyboard */
  292. #ifdef LargeInts
  293. #if COMPILER
  294.       if (largeints)
  295. #endif                    /* COMPILER */
  296.          suspend C_string "large integers";
  297. #endif                    /* LargeInts */
  298. #ifdef MathFncs
  299.       suspend C_string "math functions";
  300. #endif                    /* MathFncs */
  301. #ifdef MemMon
  302.       suspend C_string "memory monitoring";
  303. #endif                    /* MEMMON */
  304. #ifdef MultiRegion
  305.       suspend C_string "multiple regions";
  306. #endif                    /* MultiRegion */
  307. #ifdef Pipes
  308.       suspend C_string "pipes";
  309. #endif                    /* Pipes */
  310. #ifdef RecordIO
  311.       suspend C_string "record I/O";
  312. #endif                    /* RecordIO */
  313. #ifdef StrInvoke
  314.       suspend C_string "string invocation";
  315. #endif                    /* StrInvoke */
  316. #ifdef SystemFnc
  317.       suspend C_string "system function";
  318. #endif                    /* SystemFnc */
  319. #ifdef ArmFncs
  320.       suspend C_string "Archimedes extensions";
  321. #endif                    /* ArmFncs */
  322. #ifdef DosFncs
  323.       suspend C_string "MS-DOS extensions";
  324. #endif                    /* DosFncs */
  325.       fail;
  326.       }
  327. end
  328.  
  329. "&file - name of the source file for the current execution point"
  330. keyword{1} file
  331.    abstract {
  332.       return string
  333.       }
  334.    inline {
  335. #if COMPILER
  336.       if (line_info)
  337.          return C_string file_name;
  338.       else
  339.          runerr(402);
  340. #else                    /* COMPILER */
  341.       return C_string findfile(ipc.opnd);
  342. #endif                    /* COMPILER */
  343.       }
  344. end
  345.  
  346. "&host - a string identifying the host computer Icon is running on."
  347. keyword{1} host
  348.    abstract {
  349.      return string
  350.      }
  351.    inline {
  352.       char sbuf[MaxCvtLen], *tmp;
  353.       int i;
  354.  
  355.       iconhost(sbuf);
  356.       i = strlen(sbuf);
  357.       Protect(tmp = alcstr(sbuf, i), runerr(0));
  358.       return string(i, tmp);
  359.       }
  360. end
  361.  
  362. "&input - the standard input file"
  363. keyword{1} input
  364.    abstract {
  365.       return file
  366.       }
  367.    inline {
  368.       return file(&k_input);
  369.       }
  370. end
  371.  
  372. "&lcase - a cset consisting of the 26 lower case letters"
  373. keyword{1} lcase
  374.    constant 'abcdefghijklmnopqrstuvwxyz'
  375. end
  376.  
  377. "&letters - a cset consisting of the 52 letters"
  378. keyword{1} letters
  379.    constant 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
  380. end
  381.  
  382. "&level - level of procedure call."
  383. keyword{1} level
  384.    abstract {
  385.       return integer
  386.       }
  387.  
  388.    inline {
  389. #if COMPILER
  390.       if (!debug_info)
  391.          runerr(402);
  392. #endif                    /* COMPILER */
  393.       return C_integer k_level;
  394.       }
  395. end
  396.  
  397. "&line - source line number of current execution point"
  398. keyword{1} line
  399.    abstract {
  400.       return integer;
  401.       }
  402.    inline {
  403. #if COMPILER
  404.       if (line_info)
  405.          return C_integer line_num;
  406.       else
  407.          runerr(402);
  408. #else                    /* COMPILER */
  409.       return C_integer findline(ipc.opnd);
  410. #endif                    /* COMPILER */
  411.       }
  412. end
  413.  
  414. "&main - the main co-expression."
  415. keyword{1} main
  416.    abstract {
  417.       return co_expression
  418.       }
  419.    inline {
  420.       return k_main;
  421.       }
  422. end
  423.  
  424. "&null - the null value."
  425. keyword{1} null
  426.    abstract {
  427.       return null
  428.       }
  429.    inline {
  430.       return nulldesc;
  431.       }
  432. end
  433.  
  434. "&output - the standard output file."
  435. keyword{1} output
  436.    abstract {
  437.       return file
  438.       }
  439.    inline {
  440.       return file(&k_output);
  441.       }
  442. end
  443.  
  444. "&phi - the golden ratio"
  445. keyword{1} phi
  446.    constant 1.618033988749894
  447. end
  448.  
  449. "&pi - the ratio of circumference to diameter"
  450. keyword{1} pi
  451.    constant 3.141592653589793
  452. end
  453.  
  454. "&pos - a variable containing the current focus in string scanning."
  455. keyword{1} pos
  456.    abstract {
  457.       return kywdpos
  458.       }
  459.     inline {
  460.       return kywdpos(&kywd_pos);
  461.       }
  462. end
  463.  
  464. "&random - a variable containing the current seed for random operations."
  465. keyword{1} random
  466.    abstract {
  467.       return kywdint
  468.       }
  469.    inline {
  470.       return kywdint(&kywd_ran);
  471.       }
  472. end
  473.  
  474. "®ions - generates regions sizes"
  475. keyword{3} regions
  476.    abstract {
  477.       return integer
  478.       }
  479.    inline {
  480. #ifdef MultiRegion
  481.       word allRegions = 0;
  482.       struct region *rp;
  483. #endif                        /* MultiRegion */
  484. #ifdef FixedRegions
  485.       suspend C_integer 0;
  486. #else                    /* FixedRegions */
  487. #if COMPILER
  488.       suspend C_integer DiffPtrs(statend,statbase);
  489. #else                    /* COMPILER */
  490.       suspend C_integer DiffPtrs(statend,statbase) - mstksize;
  491. #endif                    /* COMPILER */
  492. #endif                    /* FixedRegions */
  493. #ifdef MultiRegion
  494.       allRegions = DiffPtrs(strend,strbase);
  495.       for (rp = curstring->next; rp; rp = rp->next)
  496.      allRegions += DiffPtrs(rp->end,rp->base);
  497.       for (rp = curstring->prev; rp; rp = rp->prev)
  498.      allRegions += DiffPtrs(rp->end,rp->base);
  499.       suspend C_integer allRegions;
  500.       allRegions = DiffPtrs(blkend,blkbase);
  501.       for (rp = curblock->next; rp; rp = rp->next)
  502.      allRegions += DiffPtrs(rp->end,rp->base);
  503.       for (rp = curblock->prev; rp; rp = rp->prev)
  504.      allRegions += DiffPtrs(rp->end,rp->base);
  505.       return C_integer allRegions;
  506. #else                    /* MultiRegion */
  507.       suspend C_integer DiffPtrs(strend,strbase);
  508.       return  C_integer DiffPtrs(blkend,blkbase);
  509. #endif                    /* MultiRegion */
  510.       }
  511. end
  512.  
  513. "&source - the co-expression that invoked the current co-expression."
  514. keyword{1} source
  515.    abstract {
  516.        return co_expression
  517.        }
  518.    inline {
  519. #ifndef Coexpr
  520.          return k_main;
  521. #else                    /* Coexpr */
  522.          return co_expression(topact((struct b_coexpr *)BlkLoc(k_current)));
  523. #endif                    /* Coexpr */
  524.          }
  525. end
  526.  
  527. "&storage - generate the amount of storage used for each region."
  528. keyword{3} storage
  529.    abstract {
  530.       return integer
  531.       }
  532.    inline {
  533. #ifdef MultiRegion
  534.       word allRegions = 0;
  535.       struct region *rp;
  536. #endif                        /* MultiRegion */
  537. #ifdef FixedRegions
  538.       suspend C_integer 0;
  539. #else                    /* FixedRegions */
  540. #if COMPILER
  541.       suspend C_integer DiffPtrs(statfree,statbase);
  542. #else                    /* COMPILER */
  543.       suspend C_integer DiffPtrs(statfree,statbase) - mstksize;
  544. #endif                    /* COMPILER */
  545. #endif                    /* FixedRegions */
  546. #ifdef MultiRegion
  547.       allRegions = DiffPtrs(strfree,strbase);
  548.       for (rp = curstring->next; rp; rp = rp->next)
  549.      allRegions += DiffPtrs(rp->free,rp->base);
  550.       for (rp = curstring->prev; rp; rp = rp->prev)
  551.      allRegions += DiffPtrs(rp->free,rp->base);
  552.       suspend C_integer allRegions;
  553.       allRegions = DiffPtrs(blkfree,blkbase);
  554.       for (rp = curblock->next; rp; rp = rp->next)
  555.      allRegions += DiffPtrs(rp->free,rp->base);
  556.       for (rp = curblock->prev; rp; rp = rp->prev)
  557.      allRegions += DiffPtrs(rp->free,rp->base);
  558.       return C_integer allRegions;
  559. #else                    /* MultiRegion */
  560.       suspend C_integer DiffPtrs(strfree,strbase);
  561.       return  C_integer DiffPtrs(blkfree,blkbase);
  562. #endif                    /* MultiRegion */
  563.       }
  564. end
  565.  
  566. "&subject - variable containing the current subject of string scanning."
  567. keyword{1} subject
  568.    abstract {
  569.       return kywdsubj
  570.       }
  571.    inline {
  572.       return kywdsubj(&k_subject);
  573.       }
  574. end
  575.  
  576. "&time - the elapsed execution time in milliseconds."
  577. keyword{1} time
  578.    abstract {
  579.       return integer
  580.       }
  581.    inline {
  582.       return C_integer millisec();
  583.       }
  584. end
  585.  
  586. "&trace - variable which controls execution tracing."
  587. keyword{1} trace
  588.    abstract {
  589.       return kywdint
  590.       }
  591.    inline {
  592.       return kywdint(&kywd_trc);
  593.       }
  594. end
  595.  
  596. "&ucase - a cset consisting of the 26 uppercase characters."
  597. keyword{1} ucase
  598.    constant 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  599. end
  600.  
  601. "&version - a string indentifying this version of Icon."
  602. keyword{1} version
  603.    constant Version
  604. end
  605.  
  606. "&lpress - left button press."
  607. keyword{1} lpress
  608.    abstract { return integer} inline { return C_integer -1; }
  609. end
  610. "&mpress - middle button press."
  611. keyword{1} mpress
  612.    abstract { return integer} inline { return C_integer -2; }
  613. end
  614. "&rpress - right button press."
  615. keyword{1} rpress
  616.    abstract { return integer} inline { return C_integer -3; }
  617. end
  618. "&lrelease - left button release."
  619. keyword{1} lrelease
  620.    abstract { return integer} inline { return C_integer -4; }
  621. end
  622. "&mrelease - middle button release."
  623. keyword{1} mrelease
  624.    abstract { return integer} inline { return C_integer -5; }
  625. end
  626. "&rrelease - right button release."
  627. keyword{1} rrelease
  628.    abstract { return integer} inline { return C_integer -6; }
  629. end
  630. "&ldrag - left button drag."
  631. keyword{1} ldrag
  632.    abstract { return integer} inline { return C_integer -7; }
  633. end
  634. "&mdrag - middle button drag."
  635. keyword{1} mdrag
  636.    abstract { return integer} inline { return C_integer -8; }
  637. end
  638. "&rdrag - right button drag."
  639. keyword{1} rdrag
  640.    abstract { return integer} inline { return C_integer -9; }
  641. end
  642. "&resize - window resize."
  643. keyword{1} resize
  644.    abstract { return integer} inline { return C_integer -10; }
  645. end
  646.  
  647. "&ascii - a cset consisting of the 128 ascii characters"
  648. keyword{1} ascii
  649. constant '\
  650. \000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\
  651. \020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\
  652. \040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057\
  653. \060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\
  654. \100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\
  655. \120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\
  656. \140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\
  657. \160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177'
  658. end
  659.  
  660. "&cset - a cset consisting of all the 256 characters."
  661. keyword{1} cset
  662. constant '\
  663. \0\1\2\3\4\5\6\7\10\11\12\13\14\15\16\17\
  664. \20\21\22\23\24\25\26\27\30\31\32\33\34\35\36\37\
  665. \40\41\42\43\44\45\46\47\50\51\52\53\54\55\56\57\
  666. \60\61\62\63\64\65\66\67\70\71\72\73\74\75\76\77\
  667. \100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\
  668. \120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\
  669. \140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\
  670. \160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177\
  671. \200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\
  672. \220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\
  673. \240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\
  674. \260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\
  675. \300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\
  676. \320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\
  677. \340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\
  678. \360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377'
  679. end
  680.